

#include "dev_flash_24c.h"
#include "stdlib.h"
#include "string.h"


static Device_t *pdev = NULL;
//static flash_item_t flash_item_buf;

static bool is_flash_init(flash_item_24c_t *buf_item);
static void read(flash_item_24c_t *buf_item);
static void write(flash_item_24c_t *buf_item);

dev_flash_t_24c dev_flash_24c = {
	.is_flash_init = is_flash_init,
	.read = read,
	.write = write,
};


static void read( flash_item_24c_t *buf_item ){
	if( NULL ==  pdev){
		pdev = findDeviceByName("flash_24c");
	}
	pdev->read(0,(uint8_t*)buf_item,sizeof(flash_item_24c_t));	
}

static void write(flash_item_24c_t *buf_item){
	if( NULL ==  pdev){
		pdev = findDeviceByName("flash_24c");
	}
	pdev->write(0,(uint8_t*)buf_item,sizeof(flash_item_24c_t));	
}


static bool is_flash_init(flash_item_24c_t *buf_item){

	if(0x55aa55aa == buf_item->flash_init_sign && 0x55aa55aa == buf_item->flash_init_sign_at_end){
		return true;
	}
	return false;	
}






